{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'snow/metro.html'"
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import plotly as py\n",
    "import pandas as pd\n",
    "import plotly.express as px\n",
    "import plotly.graph_objects as go\n",
    "pyplt = py.offline.plot\n",
    "\n",
    "line=pd.read_excel(r'dat\\metro.xlsx')\n",
    "university=pd.read_excel(r'dat\\university.xlsx')\n",
    "\n",
    "token='pk.eyJ1Ijoic3l2aW5jZSIsImEiOiJjazZrNTcwY3kwMHBrM2txaGJqZWEzNWExIn0.tLQHY_OoiR2NMxnYHXUBAA'\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "fig=px.scatter_mapbox(university,\n",
    "                                 lon='经度',\n",
    "                                 lat='纬度',\n",
    "                                 size='在读人数',\n",
    "                                  color='在读人数',\n",
    "                                 hover_name='名称',\n",
    "                                 hover_data=['区域'],\n",
    "                                 size_max=35,\n",
    "                                 color_continuous_scale=px.colors.cyclical.HSV\n",
    "                                 )\n",
    "\n",
    "fig.add_trace(go.Scattermapbox(mode='markers+lines',\n",
    "                               lon=line['经度'],\n",
    "                               lat=line['纬度'],\n",
    "                               marker={'size':9,'color':'rgb(128,0,128)' },\n",
    "                               hovertext=line['站名'],\n",
    "                               hoverinfo='text',\n",
    "                               showlegend=False))\n",
    "\n",
    "\n",
    "\n",
    "fig.update_layout(mapbox={'accesstoken':token,'center':{'lon':116.85767499999997,'lat':36.610105},'zoom':10.3,'style':'outdoors'},\n",
    "                 title={'text':'地铁网','xref':'paper','x':0.5,},\n",
    "                 margin={'l':10,'r':0,'t':50,'b':10})\n",
    "\n",
    "pyplt(fig, filename='snow/metro.html')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
